/**
 * 
 */
package anysware.gwt.client;

/**
 * TODO: doc me
 * 
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 103 $
 * @version
 */
public class ApplicationEventDispatcher implements ApplicationEventSource {
	private static final ApplicationEventDispatcher	GLOBAL_DISPATCHER	= new ApplicationEventDispatcher();

	public static final ApplicationEventDispatcher getGlobalDispatcher() {
		return GLOBAL_DISPATCHER;
	}

	private ApplicationListenerSupport	support;

	/**
	 * @param listener
	 * @see anysware.gwt.client.ApplicationListenerSupport#addListener(anysware.gwt.client.ApplicationListener)
	 */
	public void addListener(final ApplicationListener listener) {
		if (support == null) {
			support = new ApplicationListenerSupport();
		}
		support.addListener(listener);
	}

	/**
	 * @param event
	 * @see anysware.gwt.client.ApplicationListenerSupport#fireEvent(anysware.gwt.client.ApplicationEvent)
	 */
	public void fireEvent(final ApplicationEvent event) {
		if (support != null) {
			support.fireEvent(event);
		}
	}

	/**
	 * @param listener
	 * @see anysware.gwt.client.ApplicationListenerSupport#removeListener(anysware.gwt.client.ApplicationListener)
	 */
	public void removeListener(final ApplicationListener listener) {
		if (support != null) {
			support.removeListener(listener);
		}
	}
}
